package eu.livotov.jsms;

import eu.livotov.jsms.impl.GiperMobiProvider;
import eu.livotov.jsms.impl.SMPPProvider;
import eu.livotov.jsms.impl.WEBSMSProvider;

/**
 * Created with IntelliJ IDEA.
 * User: dlivotov
 * Date: 14.04.12
 * Time: 23:21
 * To change this template use File | Settings | File Templates.
 */
public class SMSProviderFactory
{

    SMSProvider getProvider(ProviderName provider, Object... args)
    {
        switch (provider)
        {
            case GIPERMOBI:
                if (args.length != 2)
                {
                    throw new IllegalArgumentException("Giper.Mobi provider requires two initial arguments: username " +
                                                               "and password.");
                }
                return new GiperMobiProvider((String)args[0], (String)args[1]);

            case WEBSMS:
                if (args.length != 2)
                {
                    throw new IllegalArgumentException("WEBSMS provider requires two initial arguments: username " +
                                                               "and password.");
                }
                return new WEBSMSProvider((String)args[0], (String)args[1]);

            case SMPP:
                if (args.length != 2)
                                {
                                    throw new IllegalArgumentException("WEBSMS provider requires 5 initial " +
                                                                               "arguments: smppHost, smppPort, smppLogin, smppPassword, smppSystemType");
                                }
                                return new SMPPProvider((String)args[0],
                                                        (Integer)args[1],
                                                        (String)args[2],
                                                        (String)args[3],
                                                        (String)args[4]);
        }

        throw new IllegalArgumentException("Unknown provider: " + provider.name());
    }

    public enum ProviderName
    {
        GIPERMOBI,
        WEBSMS,
        SMPP
    }
}
